package main

import (
	"code.google.com/p/cloud9lib/bucket"
	"code.google.com/p/cloud9lib/rest"
	_ "code.google.com/p/cloud9lib/syncd/httpd"
	"net/http"
)

var buckets = bucket.NewURLBucket("buckets")
var muxes = bucket.NewURLBucket("muxes")
var routes = bucket.NewURLBucket("routes")

func main() {

	// register root.cloud9lib.net to point to load balancer
	//routes.Put("root.cloud9lib.net/", strings.NewReader("http://localhost:8080"))

	http.Handle("/whereis", rest.HandleBucket(buckets))
	http.Handle("/bucket", rest.HandleBucket(buckets))
	http.Handle("/buckets", rest.ListBucket(buckets))
	http.Handle("/mux", rest.HandleBucket(muxes))
	http.Handle("/muxes", rest.ListBucket(muxes))
	http.Handle("/route", rest.HandleBucket(routes))
	http.Handle("/routes", rest.ListBucket(routes))

	err := http.ListenAndServe("localhost:8006", nil)

	panic(err)
}
